import { createRouter, createWebHistory } from "vue-router";
import Layout from "@/Layout/index.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "home",
      component: Layout,
      redirect: "login",
      children: [
        {
          path: "work",
          name: "work",
          children: [
            {
              path: "wait",
              name: "work_wait",
              component: () => import("@/views/work/WaitThing.vue"),
            },
            {
              path: "edit",
              name: "work_edit",
              component: () => import("@/views/work/Edit.vue"),
            },
          ],
        },
        {
          path: "system",
          name: "system",
          children: [
            {
              path: "personal",
              name: "system_personal",
              component: () => import("@/views/system/Personal.vue"),
            },
            {
              path: "user",
              name: "system_user",
              component: () => import("@/views/system/User.vue"),
            },
            {
              path: "permission",
              name: "system_permission",
              component: () => import("@/views/system/Permissions.vue"),
            },
            {
              path: "setting",
              name: "system_setting",
              component: () => import("@/views/system/Setting.vue"),
            },
          ],
        },
        {
          path: "tower",
          name: "tower_index",
          component: () => import("@/views/tower/Index.vue"),
        },
        {
          path: "route",
          name: "route_index",
          component: () => import("@/views/route/Index.vue"),
        },
        {
          path: "defect",
          name: "defect",
          children: [
            {
              path: "type",
              name: "defect_type",
              component: () => import("@/views/defects/Type.vue"),
            },
            {
              path: "level",
              name: "defect_level",
              component: () => import("@/views/defects/Level.vue"),
            },
            {
              path: "search",
              name: "defect_search",
              component: () => import("@/views/defects/Search.vue"),
            },
          ],
        },
        {
          path: "patrol",
          name: "patrol",
          children: [
            {
              path: "assign",
              name: "patrol_assign",
              component: () => import("@/views/patrol/AssignTasks.vue"),
            },
            {
              path: "execute",
              name: "patrol_execute",
              component: () => import("@/views/patrol/ExecuteTask.vue"),
            },
          ],
        },
        {
          path: "eliminate",
          name: "eliminate",
          children: [
            {
              path: "assign",
              name: "eliminate_assign",
              component: () => import("@/views/eliminate/EliminateAssign.vue"),
            },
            {
              path: "execute",
              name: "eliminate_execute",
              component: () => import("@/views/eliminate/EliminateExecute.vue"),
            },
          ],
        },
        {
          path: "record",
          name: "record",
          children: [
            {
              path: "patrol",
              name: "record_patrol",
              component: () => import("@/views/record/PatrolRecord.vue"),
            },
            {
              path: "execute",
              name: "record_eliminate",
              component: () => import("@/views/record/EliminateRecord.vue"),
            },
          ],
        },
      ],
    },
    {
      path: "/login",
      name: "login",
      component: () => import("@/views/auth/Login.vue"),
    },
  ],
});

export default router;
